//
//  ZPartyView.m
//  DoctorFAQs
//
//  Created by zjq on 17/2/15.
//  Copyright © 2017年 zjq. All rights reserved.
//

#import "ZPartyView.h"
@interface ZPartyView (){
    UIImageView * _userImgaeView;// 头像
    UILabel * _userNameLabel;
    
}
@property (nonatomic,strong) LZUserInfo * userinfo;
@end
@implementation ZPartyView
- (instancetype)init
{
    self = [super init];
    if (self) {
        [self initlizeInterface];
    }
    return self;
}
- (void)setPModel:(ZCVModel *)pModel {
    _pModel = pModel;
    NSURL * imageUrl = [NSURL URLWithString:_pModel.pic];
    [_userImgaeView sd_setImageWithURL:imageUrl placeholderImage:[UIImage imageNamed:@"icon_center_tx"]];
    _userNameLabel.text = _pModel.name;
    _timeLabel.text = _pModel.time;
}
- (void)setPerModel:(PersonInfoModel *)perModel {
    _perModel = perModel;
    NSURL * imageUrl = [NSURL URLWithString:_perModel.icon];
    [_userImgaeView sd_setImageWithURL:imageUrl placeholderImage:[UIImage imageNamed:@"icon_center_tx"]];
    _userNameLabel.text = _perModel.name;
    _timeLabel.text = _perModel.time;
}
- (void)initlizeInterface {
    _userinfo = [LZUserInfo getUserInfo];
    [self MakeSubView];
    [self addALLSubView];
    [self makeAllSubViewMasnoy];
}
- (void)MakeSubView {
    _userImgaeView = [[UIImageView alloc] init];
    _userImgaeView.image = [UIImage imageNamed:@"data_tx_140"];
    _userImgaeView.layer.cornerRadius = 15 * xsIZE;
    _userImgaeView.layer.masksToBounds = YES;
    [_userImgaeView sd_setImageWithURL:[NSURL URLWithString:_userinfo.userIcon] placeholderImage:[UIImage imageNamed:@"data_tx_140"]];
    _userNameLabel = [[UILabel alloc] init];
    _userNameLabel.text = @"";
    _userNameLabel.text = _userinfo.userName;
    _userNameLabel.textColor = KHGreenColor;
    _userNameLabel.font = [UIFont systemFontOfSize:18];
    _timeLabel = [[UILabel alloc] init];
    _timeLabel.textColor = KHGaryColor;
    _timeLabel.font = [UIFont systemFontOfSize:12];
    _timeLabel.text = @"";
    _timeLabel.textAlignment = NSTextAlignmentRight;
}
- (void)addALLSubView {
    [self addSubview:_userImgaeView];
    [self addSubview:_userNameLabel];
    [self addSubview:_timeLabel];
}
- (void)makeAllSubViewMasnoy {
    [_userImgaeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self).offset(13*xsIZE);
        make.width.height.offset(30*xsIZE);
    }];
    [_userNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_userImgaeView);
        make.left.equalTo(_userImgaeView.mas_right).offset(8*xsIZE);
        make.width.equalTo(self).multipliedBy(0.4);
        make.height.offset(18*xsIZE);
    }];
    [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY .equalTo(_userNameLabel);
        make.right.equalTo(self).offset(-10*xsIZE);
        make.height.offset(12*ysIZE);
        make.width.offset(140*xsIZE);
    }];
    
}
@end
